require('scss/base.scss');

import Vue from 'vue'
import App from './App'
import router from './routes'
import filter from './filter'
//安装Vuex
import store from 'vuex/store'

//js
import format from 'js/format'
import dayjs from 'dayjs'
import popup from 'js/popup'
import util from 'js/util'
import config from 'js/config'
import server from 'js/server'
import instruct from './instruct'
//lib
/**/
import ElementUI from 'element-ui';
Vue.use(ElementUI);
//window
// window['laydate'] = laydate;
window['dayjs'] = dayjs;
window['config'] = config;
window['router'] = router;

//单文件vue实例
// var vue = new Vue({
//     el:'#app',
//     template:'<App/>',
//     components: { App } 
// })

//mixin
Vue.mixin({
  methods: {
    routerGo(name, query) {
      var query = query || {};
      router.push({ name: name, query: query })
    }
  }
})

// 使用filter
for (var k in filter) {
  Vue.filter(k, filter[k]);
};

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || 'PGC书城管理后台'
  window.scrollTo(0, 0)
  next()
})

//vue-router&vuex实例
const vue = new Vue({
  el: '#app',
  store,
  router,
  components: { App },
  template: '<App/>'
})
window['vue'] = vue;


